@extends('admin.layout.main')

@section('content')
    <div class="breadcrumbs ace-save-state" id="breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="ace-icon fa fa-home home-icon"></i>
                <a href="/admin/index">首页</a>
            </li>
            <li>
                <a href="/admin/tpl_index">消息模板管理</a>
            </li>
            <li class="active"><a href="{{ url('admin/tpl_index') }}">消息模板列表</a></li>
        </ul><!-- /.breadcrumb -->

        {{--<div class="nav-search" id="nav-search">--}}
            {{--<form class="form-search">--}}
		{{--<span class="input-icon">--}}
		{{--<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />--}}
			{{--<i class="ace-icon fa fa-search nav-search-icon"></i>--}}
		{{--</span>--}}
            {{--</form>--}}
        {{--</div><!-- /.nav-search -->--}}
    </div>
    <form class="form-search" action="/admin/tpl_index" method="post">
        <span class="page-content">消息标题：</span>
        <span class="input-icon">
        <input type="hidden" name="_token" value="{{csrf_token()}}"/>
		<input type="text"  name="like_title" value="{{$like_title}}" class="nav-search-input" id="nav-search-input" autocomplete="off" />
		</span>
        <button class="btn btn-info" type="submit" >
            查找
        </button>
        </span>
    </form>
    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="row">
                    <div class="col-xs-12">
                        <div class="clearfix">
                            <div class="pull-right tableTools-container"></div>
                        </div>
                        <div class="table-header">
                            <a href="{{ url('admin/tpl_create') }}">
                                <i class="menu-icon fa fa-plus orange"></i>
                                <span class="menu-text orange"> 添加系统消息模板 </span>
                            </a>
                        </div>

                        <!-- div.table-responsive -->

                        <!-- div.dataTables_borderWrap -->
                        <div>
                            <table id="dynamic-table" class="table table-striped table-bordered table-hover">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>消息类型</th>
                                    <th>消息标题</th>
                                    <th>消息模板</th>
                                    <th>推送模板</th>
                                    <th class="hidden-480">添加时间</th>
                                    <th>
                                        <i class="ace-icon fa fa-clock-o bigger-110 hidden-480"></i>
                                        更新时间
                                    </th>
                                    <th>管理员</th>
                                    <th class="hidden-480">操作</th>

                                    {{--<th></th>--}}
                                </tr>
                                </thead>

                                <tbody>
                                @foreach($list as $key=>$data)
                                    <tr>
                                        <td>{{$page_num++}}</td>
                                        <td>【{{$msg_name[$data->name]}}】</td>
                                        <td>{{$data->title}}</td>
                                        <td>{{$data->message}}</td>
                                        <td>{{$data->push_message}}</td>
                                        <td>{{$data->created_at}}</td>
                                        <td>{{$data->updated_at}}</td>
                                        <td>{{$data->admin->username}}</td>

                                        <td><div class="hidden-sm hidden-xs action-buttons">
                                                {{--<a class="blue" href="#">--}}
                                                    {{--<i class="ace-icon fa fa-search-plus bigger-130"></i>--}}
                                                {{--</a>--}}

                                                <a class="green" href="/admin/tpl_edit/{{$data->id}}">
                                                    <i class="ace-icon fa fa-pencil bigger-130"></i>
                                                </a>

                                                <a class="red" href="javascript:void(0);" onclick="delData('{{$data->id}}')">
                                                    <i class="ace-icon fa fa-trash-o bigger-130"></i>
                                                </a>
                                            </div>

                                            <div class="hidden-md hidden-lg">
                                                <div class="inline pos-rel">
                                                    <button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown" data-position="auto">
                                                        <i class="ace-icon fa fa-caret-down icon-only bigger-120"></i>
                                                    </button>

                                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                                        {{--<li>--}}
                                                            {{--<a href="#" class="tooltip-info" data-rel="tooltip" title="View">--}}
															{{--<span class="blue">--}}
																{{--<i class="ace-icon fa fa-search-plus bigger-120"></i>--}}
															{{--</span>--}}
                                                            {{--</a>--}}
                                                        {{--</li>--}}

                                                        <li>
                                                            <a href="/admin/tpl_edit/{{$data->id}}" class="tooltip-success" data-rel="tooltip" title="Edit">
															<span class="green">
																<i class="ace-icon fa fa-pencil-square-o bigger-120"></i>
															</span>
                                                            </a>
                                                        </li>

                                                        <li>
                                                            <a href="javascript:void(0);" onclick="delData('{{$data->id}}')" class="tooltip-error" data-rel="tooltip" title="Delete">
															<span class="red">
																<i class="ace-icon fa fa-trash-o bigger-120"></i>
															</span>
                                                            </a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->

            <div class="modal-footer no-margin-top">
                @if(empty($url_data))
                    {{ $list->links() }}
                @else
                    {{$list->appends($url_data)->links() }}
                @endif
            </div>
        </div><!-- /.row -->
    </div><!-- /.page-content -->

    <script>
        function delData(id) {
            var url = '{{url('admin/tpl_destroy')}}';
            $.get(url,{id:id},function(res){
                if(res.status == 1){
                    layer.msg(res.msg,{icon:1});
                    location.reload();
                }else{
                    layer.msg(res.msg,{icon:2});
                }
            })
        }
    </script>
@endsection
